package com.zabra.zl.ui.allocation_plan;

import android.graphics.Color;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.orhanobut.logger.Logger;
import com.zabra.zl.R;
import com.zabra.zl.data.MultipleRuleBean;

import java.util.List;

public class Adp extends BaseQuickAdapter<MultipleRuleBean.RespDataBean, BaseViewHolder> {
    private int selectItem = -1;
    private String money;

    public Adp(int layoutResId, @Nullable List<MultipleRuleBean.RespDataBean> data, String money) {
        super(layoutResId, data);
        this.money = money;
    }

    public void setMoney(String money1) {
        money = money1;
        notifyDataSetChanged();
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, MultipleRuleBean.RespDataBean item) {
        double v = Double.parseDouble(money);
        int times = item.getTimes();
        helper.setText(R.id.item_multiple, item.getTimes() + "")
                .setText(R.id.item_isfree, "利率" + item.getSingleRate() + "%")
                .setText(R.id.item_money, (v * times) + "元");
        if (helper.getAdapterPosition() == selectItem) {
            //选中
            helper.setTextColor(R.id.item_multiple, Color.parseColor("#FFFFFF"));
            helper.setTextColor(R.id.item_bei, Color.parseColor("#FFFFFF"));
            helper.setTextColor(R.id.item_isfree, Color.parseColor("#FFFFFF"));
            helper.setTextColor(R.id.item_money, Color.parseColor("#FFFFFF"));
            helper.setBackgroundColor(R.id.item_view, Color.parseColor("#ff2f25"));
        } else {
            //未选中
            helper.setTextColor(R.id.item_multiple, Color.parseColor("#999999"));
            helper.setTextColor(R.id.item_bei, Color.parseColor("#999999"));
            helper.setTextColor(R.id.item_isfree, Color.parseColor("#999999"));
            helper.setTextColor(R.id.item_money, Color.parseColor("#999999"));
            helper.setBackgroundRes(R.id.item_view, R.drawable.allocation_plan_unselect);
        }
    }

    public void setSelectItem(int selectItem) {
        this.selectItem = selectItem;
    }

}
